<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue</title>
    <script src="./vue.js"></script>
    <style>
        #root {
            width: 500px;
            margin: 200px auto;
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="root">
    </div>
    <script>
        Vue.config.productionTip = false

        // 一个重要的的内置关系: VueComponent.prototype.__photo__ === Vue.component
        // 这样使VueComponebts可以访问到Vue的属性和方法，让Vue兜底，就复用了很多代码
        const school = Vue.extend({
            template: `
            <div>
                <span>学校名称：{{schoolName}}</span>
                <span>学校地址：{{schoolAddress}}</span>
                <button @click='tips'>click me</button>
            </div>
            `,
            data() {
                return {
                    schoolName: 'XAUT',
                    schoolAddress: '雁塔'
                }
            },
            methods: {
                tips() {
                    alert('tips')
                }
            }
        })
        const student = Vue.extend({
            template: `
            <div>
                <span>学生姓名：{{studentName}}</span>
                <span>学生地址：{{studentAddress}}</span>
            </div>
            `,
            data() {
                return {
                    studentName: 'chen',
                    studentAddress: '桥洞'
                }
            }
        })
        Vue.component('student', student)
        const vm = new Vue({
            el: '#root',
            components: {
                xuexiao: school,
                xuesheng: student
            },
            computed: {},
            watch: {},
            methods: {},
            directives: {},
        })
    </script>
</body>

</html>